/***************************************************************************
 *   Copyright (C) 2006 by Archimedes Projekt   *
 *   thelsb@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef QHKP_H
#define QHKP_H

#include <QFile>

/**
A Qt wraper class for the HackerPort driver

	@author Archimedes Projekt <thelsb@gmail.com>
*/

//macro for number of elements in an array
#define arrElements( array ) (sizeof( (array) ) / sizeof( (array)[0] ))


class QHkp : public QFile
{
Q_OBJECT
public:
  enum port{A='A',B, analogA, analogB, analogC, analogD, analogE, analogAll };
public:
    QHkp(QString hkpDev="/dev/hkp0",QObject *parent = 0, const char *name = 0);
    ~QHkp();
    QString& device();
    void setHkpDevice(const QString &dev);
    QHkp& operator=(const QHkp& instance);
    int ownInputPort(port p);
    int ownOutputPort(port p);

protected:
    QString m_dev; //device name
    int m_hkp_fd; //hkp device descriptor
    bool m_open;
public slots:
    int writeData(port p, unsigned char data);
    int readData(port p,unsigned char *data);
    
signals:
    void dataReady(unsigned char);    

};

#endif


